package cn.wolfcode.p2p.base.domain;

import cn.wolfcode.p2p.base.util.BitStateUtil;
import jdk.nashorn.internal.objects.annotations.Setter;
import lombok.Getter;

//用户的基本信息
@Getter@lombok.Setter
public class UserInfo extends BaseDomain {
    private int version;//乐观锁
    private Long bitState = 0L;//用户状态码
    private String realName;//真实姓名
    private String idNumber;//身份证号码
    private String phoneNumber;//手机号码
    private String email;//邮箱
    private Long realAuthId;//实名认证
    private Long videoAuthId;//视频认证
    private SystemDictionaryItem incomeGrade;//收入情况
    private SystemDictionaryItem marriage;//婚姻情况
    private SystemDictionaryItem kidCount; //子女情况
    private SystemDictionaryItem educationBackground;//学历情况
    private SystemDictionaryItem houseCondition;//住房情况

    public boolean isHasBasicInfo(){
        return BitStateUtil.hasState(this.bitState,BitStateUtil.HAS_BASIC_INFO);
    }

    public boolean isHasRealAuth(){
        return BitStateUtil.hasState(this.bitState,BitStateUtil.HAS_REAL_AUTH);
    }

    public boolean isHasVideoAuth(){
        return BitStateUtil.hasState(this.bitState,BitStateUtil.HAS_VIDEO_AUTH);
    }

    public boolean isCanBorrow(){
        //判断当前用户借贷要求信息,
        return this.isHasBasicInfo()&&this.isHasRealAuth()&&this.isHasVideoAuth();
    }

    public boolean isHasBidRequestApplyProcess(){
        return BitStateUtil.hasState(this.bitState,BitStateUtil.HAS_BIDREQUEST_APPLY_PROCESS);
    }

    public void addState(Long state){
        this.bitState = BitStateUtil.addState(this.bitState, state);
    }

    public void removeState(Long state) {
        this.bitState = BitStateUtil.removeState(this.bitState,state);
    }
}

